package com.mzz.structure.proxy.proxyaop;

import java.lang.reflect.Method;

/**
 *
 * @author xushijian
 * @date 18/6/5 上午9:53
 */
public class CalculatorHandler extends AbstractHandler {

    private Object target;

    public CalculatorHandler(Object object) {
        this.target = object;
    }

    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        new BeforeHandler() {
            @Override
            public void handlBefore(Object proxy, Method method, Object[] args) {
                System.out.println("start ... Pre ....");
            }
        }.invoke(proxy, method, args);

        System.out.println("执行核心业务  。。。。");

        Object obj = method.invoke(target, args);

        new AfterHandler() {
            @Override
            public void handleAfter(Object proxy, Method method, Object[] args) {
                System.out.println("end ...event ...");
            }
        }.invoke(proxy, method, args);

        return obj;
    }


}
